package com.ttyec.park;

import android.content.Context;
import android.view.Gravity;
import android.widget.Toast;

public class Utils {
    public static final int HANDLER_START = 100; //启动网络service 消息
    public static final int HANDLER_START_NETWORK = 101; //启动网络摄像机连接
    public static final int HANDLER_TOAST = 102; //toast 消息显示
    public static final int HANDLER_TEST = 103; //toast 消息显示



    /**从网络获取配置信息*/
    public static final int HANDLER_SET = 1000; //网络设置信息


    //sharedPreferencesHelper的key
    public static final String SP_LOCALSET = "LOCALSET";
    public static final String SP_SERVERIP = "SERVERIP";
    public static final String SP_TOKEN = "TOKEN";
    public static final String SP_BASESET = "BASESET";
    public static final String SP_WS_URL = "SP_WS_URL";  // webSocket的地址
    public static final String SP_WS_HOST = "SP_WS_HOST";  // Socket的 ip
    public static final String SP_WS_TOKEN = "SP_WS_TOKEN";  // Socket的 port


    //封装的toast
    private static Toast toast;

    public static void showToast(final Context context, final String message) {
        showToast(context, message, false);
    }

    public static void showToast(final Context context, final String message, final boolean center) {
        if (toast == null) {
            toast = Toast.makeText(context, message, Toast.LENGTH_SHORT);
        } else {
            toast.setText(message);
        }
        if (center) {
            toast.setGravity(Gravity.CENTER, 0, 0);
        }
        toast.show();
    }
}
